#include "QGroupCompare.h"
#include <assert.h>

QGroupCompare::QGroupCompare(QWidget *parent) :
    QWidget(parent)
{
	//string group1Path="E:/groupDesk0.txt";
	//string group2Path="E:/groupDesk29.txt";

	//string group1Path="E:/conferenceroom/groups/groupDesk/groupDesk0.txt";
	//string group2Path="E:/conferenceroom/groups/groupDesk/groupDesk5.txt";

	string group1Path="E:/conferenceroom/groups/groupTable/groupTable0.txt";
	string group2Path="E:/conferenceroom/groups/groupTable/groupTable6.txt";

	group1=new GGroup;
	group2=new GGroup;

	
	ReadGroup(group1,group1Path);
	ReadGroup(group2,group2Path);

	//group1->elements[0]->RotateByModel(group2->elements[0]);
	//group1->elements[0]->ApplyTransXF();

	//group1->need_BboxSphere();

	//group2->need_BboxSphere();

	OriginGroupWidget=new QGroupDisplay;
	OriginGroupWidget->SetDisGroup(group1);

	TargetGroupWidget=new QGroupDisplay;
	TargetGroupWidget->SetDisGroup(group2);

	hlayout=new QHBoxLayout;
	hlayout->addWidget(OriginGroupWidget);
	hlayout->addWidget(TargetGroupWidget);

	this->setLayout(hlayout);
}

QGroupCompare::~QGroupCompare()
{

}

void QGroupCompare::ReadGroup( GGroup* group,string path )
{
	ifstream groupIn(path);
	if(!groupIn.is_open())
		assert(false);
	group->ReadGFile(groupIn);
	groupIn.close();

	group->ReadMeshes();
	group->need_BboxSphere();

	//group->ExtractDescriptors();
}
